/**
 * 
 */
var api, W;
var cansle_dept = function(){
	api.close();
};

var initDialog=function(){

    api = frameElement.api;W = api.opener;
    
    initTables(api.data);
    
};

var initTables = function(validData){
	$('#enterprise').dataTable({
		"bProcessing" : true, //DataTables载入数据时，是否显示‘进度’提示
        "bServerSide" : true, //是否启动服务器端数据导入
        "bStateSave" : false, //是否打开客户端状态记录功能,此功能在ajax刷新纪录的时候不会将个性化设定回复为初始化状态
        "bJQueryUI" : true, //是否使用 jQury的UI theme
        "aLengthMenu" : [5, 10, 15], //更改显示记录数选项
        "iDisplayLength" : 10, //默认显示的记录数
        "bAutoWidth" : true, //是否自适应宽度 update\
        "bScrollCollapse" : false, //是否开启DataTables的高度自适应，当数据条数不够分页数据条数的时候，插件高度是否随数据条数而改变
        "bPaginate" : false, //是否显示（应用）分页器
        "bInfo" : false, //是否显示页脚信息，DataTables插件左下角显示记录数
        "sPaginationType" : "full_numbers", //详细分页组，可以支持直接跳转到某页
        "bSort" : true, //是否启动各个字段的排序功能
        "aaSorting" : [[0, "ASC"]], //默认的排序方式，第3列，升序排列
        "bFilter" : false, //是否启动过滤、搜索功能
        "sScrollX": "100%",
		"sScrollXInner": 1150,
        "sPaginationType": "full_numbers",
	    "sAjaxSource":"sys/SensitiveValidExt/list",
        "fnServerData": function( sSource, aoData, fnCallback ) {
	       $.each(validData,function(key,value){
	    	   aoData.push({name:key,value:value});
	        });
         $.ajax( {
	                type: "POST", 
	                url: sSource, 
	                cache : false,
	                dataType : "json",
	                data : aoData, 
	                success: function(resp) {
	                	if(resp && resp.state == 200){
	                		fnCallback(resp.datagrid);
	                		return false;
	                	}
	                	fnCallback(null);
	            }
	        });
     },  
	"aoColumns" : [ {
			"mDataProp" : "subtleName",
			"sTitle" : "客户姓名",
			"bSortable": true,
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"150px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validLoanBorrower]'])  &&  data == validData['queryProxy[validLoanBorrower]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		}, {
			"mDataProp" : "subtleSex",
			"sTitle" : "客户性别",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
			      return top.SYS_BASE_DATA['Client_Sex_Code'][data];
				}
		}, {
			"mDataProp" : "subtleIdCard",
			"sTitle" : "证件号码",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validClientCardId]'])  &&  data == validData['queryProxy[validClientCardId]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		}, 
		{
			"mDataProp" : "subtleIdAddress",
			"sTitle" : "身份证地址",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
			      return data;
				}
		}, 
		{
			"mDataProp" : "subtleMobile",
			"sTitle" : "手机号码",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validClientMobile]'])  &&  data == validData['queryProxy[validClientMobile]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		},
		{
			"mDataProp" : "subtleWork",
			"sTitle" : "公司名称",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validWorkCompany]'])  &&  data == validData['queryProxy[validWorkCompany]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		},
		{
			"mDataProp" : "subtleWorkRegisterNumber",
			"sTitle" : "公司注册号",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validWorkLicense]'])  &&  data == validData['queryProxy[validWorkLicense]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		},
		{
			"mDataProp" : "subtleSpouseName",
			"sTitle" : "配偶名称",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validSpouseName]'])  &&  data == validData['queryProxy[validSpouseName]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		}, 
		{
			"mDataProp" : "subtleSpouseMobile",
			"sTitle" : "配偶手机",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validSpousePhone]'])  &&  data == validData['queryProxy[validSpousePhone]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		}, 
		{
			"mDataProp" : "subtleSpouseCardId",
			"sTitle" : "配偶身份证",
			"sDefaultContent" : "",
			"sClass" : "center",
			"sWidth":"100px",
			"mRender": function (data, display, row) {
				  if(_is_not_empty(data) &&  _is_not_empty( validData['queryProxy[validSpouseCardId]'])  &&  data == validData['queryProxy[validSpouseCardId]'] ){
					  return  '<div style="color: red;">'+(data)+'</div>';
				  }
			      return data||'';
				}
		}
		],
		"oLanguage": {
            "sUrl":"static_resources/language/lang-cn.txt" //这个是国际化，也就是汉化的各种文字数据源，写对url就行了
        }
	});
};
$(document).ready(function() {
	initDialog();
});



